<?php /*a:3:{s:77:"D:\phpstudy_pro\WWW\git\DSShop\app\admin\view\vrgroupbuy\groupbuy_add_vr.html";i:1591325525;s:64:"D:\phpstudy_pro\WWW\git\DSShop\app\admin\view\public\header.html";i:1571626691;s:69:"D:\phpstudy_pro\WWW\git\DSShop\app\admin\view\public\admin_items.html";i:1566788179;}*/ ?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>DSShop单店铺商城系统后台</title>
        <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
        <link rel="stylesheet" href="<?php echo htmlentities(ADMIN_SITE_ROOT); ?>/css/admin.css">
        <link rel="stylesheet" href="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/js/jquery-ui/jquery-ui.min.css">
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/jquery-2.1.4.min.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/jquery.validate.min.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/jquery.cookie.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/common.js"></script>
        <script src="<?php echo htmlentities(ADMIN_SITE_ROOT); ?>/js/admin.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/js/jquery-ui/jquery-ui.min.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/js/jquery-ui/jquery.ui.datepicker-zh-CN.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/perfect-scrollbar.min.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/layer/layer.js"></script>
        <script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/js/dialog/dialog.js" id="dialog_js" charset="utf-8"></script>

        <script type="text/javascript">
            var BASESITEROOT = "<?php echo htmlentities(BASE_SITE_ROOT); ?>";
            var ADMINSITEROOT = "<?php echo htmlentities(ADMIN_SITE_ROOT); ?>";
            var BASESITEURL = "<?php echo htmlentities(BASE_SITE_URL); ?>";
            var HOMESITEURL = "<?php echo htmlentities(HOME_SITE_URL); ?>";
            var ADMINSITEURL = "<?php echo htmlentities(ADMIN_SITE_URL); ?>";
        </script>
    </head>
    <body>
        <div id="append_parent"></div>
        <div id="ajaxwaitid"></div>








<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>抢购管理</h3>
                <h5></h5>
            </div>
            <?php if($admin_item): ?>
<ul class="tab-base ds-row">
    <?php if(is_array($admin_item) || $admin_item instanceof \think\Collection || $admin_item instanceof \think\Paginator): if( count($admin_item)==0 ) : echo "" ;else: foreach($admin_item as $key=>$item): ?>
    <li><a href="<?php echo htmlentities($item['url']); ?>" <?php if($item['name'] == $curitem): ?>class="current"<?php endif; ?>><span><?php echo htmlentities($item['text']); ?></span></a></li>
    <?php endforeach; endif; else: echo "" ;endif; ?>
</ul>
<?php endif; ?>
        </div>
    </div>
    
    
    <form id="add_form" action="" method="post" enctype="multipart/form-data" class="dssc-form-default">
        <dl>
            <dt><i class="required">*</i><?php echo htmlentities(lang('group_name')); ?><?php echo htmlentities(lang('ds_colon')); ?></dt>
            <dd>
                <input class="w400 text" name="groupbuy_name" type="text" id="groupbuy_name" value="" maxlength="30"  />
                <span></span>
                <p class="hint"><?php echo htmlentities(lang('group_name_tip')); ?></p>
            </dd>
        </dl>
        <dl>
            <dt><?php echo htmlentities(lang('snap_up_subtitles')); ?><?php echo htmlentities(lang('ds_colon')); ?></dt>
            <dd>
                <input class="w400 text" name="remark" type="text" id="remark" value="" maxlength="30"  />
                <span></span>
                <p class="hint"><?php echo htmlentities(lang('snap_up_subtitle_word_limit')); ?></p>
            </dd>
        </dl>
        <dl>
            <dt><i class="required">*</i><?php echo htmlentities(lang('start_time')); ?><?php echo htmlentities(lang('ds_colon')); ?></dt>
            <dd>
                <input id="start_time" name="start_time" type="text" class="text w130" /><em class="add-on"><i class="iconfont">&#xe8d6;</i></em><span></span>
                <p class="hint"><?php echo htmlentities(lang('start_time_cannot_less_than')); ?></p>
            </dd>
        </dl>
        <dl>
            <dt><i class="required">*</i><?php echo htmlentities(lang('end_time')); ?><?php echo htmlentities(lang('ds_colon')); ?></dt>
            <dd>
                <input id="end_time" name="end_time" type="text" class="text w130"/><em class="add-on"><i class="iconfont">&#xe8d6;</i></em><span></span>
                <p class="hint">
                    <?php echo htmlentities(lang('no_more_buying_virtual_goods')); ?>
                    <span id="vr-expire-time"></span>
                </p>
            </dd>
        </dl>

        <dl>
            <dt><i class="required">*</i><?php echo htmlentities(lang('groupbuy_goods')); ?><?php echo htmlentities(lang('ds_colon')); ?></dt>
            <dd>
                <div dstype="groupbuy_goods_info" class="selected-group-goods " style="display:none;">
                    <div class="goods-thumb"><img id="groupbuy_goods_image" src=""/></div>
                    <div class="goods-name">
                        <a dstype="groupbuy_goods_href" id="groupbuy_goods_name" href="" target="_blank"></a>
                    </div>
                    <div class="goods-price"><?php echo htmlentities(lang('groupbuy_index_price')); ?>：￥<span dstype="groupbuy_goods_price"></span></div>
                </div>
                <a href="javascript:void(0);" id="btn_show_search_goods" class="dssc-btn dssc-btn-acidblue"><?php echo htmlentities(lang('groupbuy_index_choose_goods')); ?></a>
                <input id="groupbuy_goods_id" name="groupbuy_goods_id" type="hidden" value=""/>
                <span></span>
                <div id="div_search_goods" class="div-goods-select mt10" style="display: none;">
                    <table class="search-form">
                        <tr>
                            <th class="w150">
                                <strong><?php echo htmlentities(lang('search_items')); ?></strong>
                            </th>
                            <td class="w160">
                                <input id="search_goods_name" type="text w150" class="text" name="goods_name" value=""/>
                            </td>
                            <td class="w70 tc">
                                <a href="javascript:void(0);" id="btn_search_goods" class="dssc-btn"/><i class="iconfont">&#xe718;</i><?php echo htmlentities(lang('ds_search')); ?></a></td>
                            <td class="w10"></td>
                            <td>
                                <p class="hint"><?php echo htmlentities(lang('display_all_virtual_goods')); ?>。</p>
                            </td>
                        </tr>
                    </table>
                    <div id="div_goods_search_result" class="search-result" style="width:739px;"></div>
                    <a id="btn_hide_search_goods" class="close" href="javascript:void(0);">X</a>
                </div>
                <p class="hint"><?php echo htmlentities(lang('groupbuy_goods_explain')); ?></p>
            </dd>
        </dl>
        <dl dstype="groupbuy_goods_info" style="display:none;">
            <dt><?php echo htmlentities(lang('groupbuy_index_price')); ?><?php echo htmlentities(lang('ds_colon')); ?></dt>
            <dd> <?php echo htmlentities(lang('currency')); ?><span dstype="groupbuy_goods_price"></span></dd>
        </dl>
        <dl>
            <dt><i class="required">*</i><?php echo htmlentities(lang('groupbuy_price')); ?><?php echo htmlentities(lang('ds_colon')); ?></dt>
            <dd>
                <input class="w70 text" id="groupbuy_price" name="groupbuy_price" type="text" value=""/><em class="add-on"><i class="iconfont">&#xe65c;</i></em> <span></span>
                <p class="hint"><?php echo lang('groupbuy_price_tip'); ?></p>
            </dd>
        </dl>
        <dl>
            <dt><i class="required">*</i><?php echo htmlentities(lang('snap_up_photos')); ?><?php echo htmlentities(lang('ds_colon')); ?></dt>
            <dd>
                <div class="dssc-upload-thumb groupbuy-pic">
                    <p><i class="iconfont">&#xe72a;</i>
                        <img dstype="img_groupbuy_image" style="display:none;" src=""/></p>
                </div>
                <input dstype="groupbuy_image" name="groupbuy_image" type="hidden" value="">
                <div class="dssc-upload-btn">
                    <a href="javascript:void(0);">
                        <span>
                            <input type="file" hidefocus="true" size="1" class="input-file" name="groupbuy_image" dstype="btn_upload_image"/>
                        </span>
                        <p><i class="iconfont">&#xe733;</i><?php echo htmlentities(lang('image_upload')); ?></p>
                    </a>
                </div>
                <span></span>
                <p class="hint"><?php echo lang('group_pic_explain'); ?></p>
            </dd>
        </dl>
        <dl>
            <dt><?php echo htmlentities(lang('snap_recommended_images')); ?><?php echo htmlentities(lang('ds_colon')); ?></dt>
            <dd>
                <div class="dssc-upload-thumb groupbuy-commend-pic">
                    <p><i class="iconfont">&#xe72a;</i>
                        <img dstype="img_groupbuy_image" style="display:none;" src=""/></p>
                </div>
                <input dstype="groupbuy_image" name="groupbuy_image1" type="hidden" value="">
                <span></span>
                <div class="dssc-upload-btn">
                    <a href="javascript:void(0);">
                        <span>
                            <input type="file" hidefocus="true" size="1" class="input-file" name="groupbuy_image" dstype="btn_upload_image"/>
                        </span>
                        <p><i class="iconfont">&#xe733;</i><?php echo htmlentities(lang('image_upload')); ?></p>
                    </a>
                </div>
                <p class="hint"><?php echo lang('group_pic_explain2'); ?></p>
            </dd>
        </dl>
        <dl>
            <dt><?php echo htmlentities(lang('snap_classification')); ?><?php echo htmlentities(lang('ds_colon')); ?></dt>
            <dd>
                <select id="class" name="class" class="w80">
                    <option value=""><?php echo htmlentities(lang('ds_please_choose')); ?></option>
                    <?php if(!(empty($classlist) || (($classlist instanceof \think\Collection || $classlist instanceof \think\Paginator ) && $classlist->isEmpty()))): if(is_array($classlist) || $classlist instanceof \think\Collection || $classlist instanceof \think\Paginator): if( count($classlist)==0 ) : echo "" ;else: foreach($classlist as $key=>$val): ?>
                    <option value="<?php echo htmlentities($val['vrgclass_id']); ?>"><?php echo htmlentities($val['vrgclass_name']); ?></option>
                    <?php endforeach; endif; else: echo "" ;endif; ?>
                    <?php endif; ?>
                </select>
                <select id="s_class" name="s_class" class="w80">
                    <option value=""><?php echo htmlentities(lang('ds_please_choose')); ?></option>
                </select>
                <span></span>
                <p class="hint"><?php echo htmlentities(lang('select_category_virtual_panic_buying')); ?></p>
            </dd>
        </dl>
        <dl>
            <dt><?php echo htmlentities(lang('virtual_quantity')); ?><?php echo htmlentities(lang('ds_colon')); ?></dt>
            <dd>
                <input class="w70 text" id="virtual_quantity" name="virtual_quantity" type="text" value="0"/>
                <span></span>
                <p class="hint"><?php echo htmlentities(lang('virtual_quantity_explain')); ?></p>
            </dd>
        </dl>
        <dl>
            <dt><?php echo htmlentities(lang('sale_quantity')); ?><?php echo htmlentities(lang('ds_colon')); ?></dt>
            <dd>
                <input class="w70 text" id="upper_limit" name="upper_limit" type="text" value="0"/>
                <span></span>
                <p class="hint"><?php echo htmlentities(lang('maximum_quantity_available')); ?></p>
            </dd>
        </dl>
        <dl>
            <dt><?php echo htmlentities(lang('group_intro')); ?><?php echo htmlentities(lang('ds_colon')); ?></dt>
            <dd>
                <?php echo build_editor(['name'=>'groupbuy_intro','content'=>'']); ?>

                <textarea name="groupbuy_intro" id="groupbuy_intro"></textarea>

                <p class="hr8"><a class="des_demo dssc-btn" href="<?php echo url('Goodsalbum/pic_list',['item'=>'groupbuy']); ?>"><i class="iconfont">&#xe72a;</i><?php echo htmlentities(lang('goods_album_insert_users_photo')); ?></a></p>
                <p id="des_demo" style="display:none;"></p>
            </dd>
        </dl>
        <div class="bottom">
            <input type="submit" class="btn" value="<?php echo htmlentities(lang('ds_submit')); ?>">
        </div>
    </form>
    
    
    
<link rel="stylesheet" href="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/js/jquery-ui-timepicker/jquery-ui-timepicker-addon.min.css">
<script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/js/jquery-ui-timepicker/jquery-ui-timepicker-addon.min.js"></script>
<script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/js/jquery-ui-timepicker/i18n/jquery-ui-timepicker-zh-CN.js"></script>
<script src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/js/jquery-file-upload/jquery.fileupload.js"></script>
<script type="text/javascript" src="<?php echo htmlentities(PLUGINS_SITE_ROOT); ?>/jquery.ajaxContent.pack.js" ></script> 
<script type="text/javascript">
    $(document).ready(function(){

        $("select[name=class]").change(function(){
            var vrgclass_id = $(this).val();
            $.ajax({
                type:'GET',
                url:"<?php echo url('Vrgroupbuy/ajax_vr_class'); ?>",
                data:{vrgclass_id:+vrgclass_id},
                success:function(json){
                    var html = '<option value="">'+'<?php echo htmlentities(lang('ds_please_choose')); ?>'+'</option>';
                    if(json){
                        var data = eval("("+json+")");
                        $.each(data,function(i,val){
                            html+='<option value="'+val.vrgclass_id+'">'+val.vrgclass_name+'</option>';
                        });
                    }
                    $("select[name=s_class]").html(html);
                }
            });
        });


        $('#start_time').datetimepicker({dateFormat: 'yy-mm-dd'});
        $('#end_time').datetimepicker({dateFormat: 'yy-mm-dd'});

        $('#btn_show_search_goods').on('click', function() {
            $('#div_search_goods').show();
        });

        $('#btn_hide_search_goods').on('click', function() {
            $('#div_search_goods').hide();
        });

        //搜索商品
        $('#btn_search_goods').on('click', function() {
            var url = "<?php echo url('Vrgroupbuy/search_vr_goods'); ?>";
            var datas =  $.param({goods_name: $('#search_goods_name').val()});
            $('#div_goods_search_result').load(url,datas);
        });

        $('#div_goods_search_result').on('click', '.pagination li a', function() {
            $('#div_goods_search_result').load($(this).attr('href'));
            return false;
        });

        var vrExpireTime = 0;
        var vrLimitNum = 0;

        //选择商品
        $('#div_goods_search_result').on('click', '[dstype="btn_add_groupbuy_goods"]', function() {
            var goods_commonid = $(this).attr('data-goods-commonid');
            $.get("<?php echo url('Vrgroupbuy/groupbuy_goods_info'); ?>", {goods_commonid: goods_commonid}, function(data) {
                if(data.result) {
                    $('#groupbuy_goods_id').val(data.goods_id);
                    $('#groupbuy_goods_image').attr('src', data.goods_image);
                    $('#groupbuy_goods_name').text(data.goods_name);
                    $('[dstype="groupbuy_goods_price"]').text(data.goods_price);
                    $('[dstype="groupbuy_goods_href"]').attr('href', data.goods_href);
                    $('[dstype="groupbuy_goods_info"]').show();
                    $('#div_search_goods').hide();
                    // vr
                    vrExpireTime = '' + data.virtual_indate;
                    $('#vr-expire-time').html('（'+data.virtual_indate_str+'）');
                    vrLimitNum = data.virtual_limit;
                } else {
                    layer.msg(data.message);
                }
            }, 'json');
        });

        //图片上传
        $('[dstype="btn_upload_image"]').fileupload({
            dataType: 'json',
            url: "<?php echo url('Groupbuy/image_upload'); ?>",
            add: function(e, data) {
                $parent = $(this).parents('dd');
                $input = $parent.find('[dstype="groupbuy_image"]');
                $img = $parent.find('[dstype="img_groupbuy_image"]');
                data.formData = {old_groupbuy_image:$input.val()};
                $img.attr('src', "<?php echo htmlentities(HOME_SITE_ROOT); ?>/images/loading.gif");
                data.submit();
            },
            done: function (e,data) {
                var result = data.result;
                $parent = $(this).parents('dd');
                $input = $parent.find('[dstype="groupbuy_image"]');
                $img = $parent.find('[dstype="img_groupbuy_image"]');
                if(result.result) {
                    $img.prev('i').hide();
                    $img.attr('src', result.file_url);
                    $img.show();
                    $input.val(result.file_name);
                } else {
                    layer.msg(data.message);
                }
            }
        });

        jQuery.validator.methods.lessThanVrLimitNum = function(value, element) {
            var v = parseInt(value) || 0;
            if (v > 0 && vrLimitNum && vrLimitNum > 0 && v > vrLimitNum)
                return false;
            return true;
        };

        jQuery.validator.methods.lessThanVrExpireTime = function(value, element) {
            var ts = new Date(Date.parse(value.replace(/-/g, "/"))).getTime() / 1000;
            // console.log(vrExpireTime);
            // console.log(ts);
            return vrExpireTime > ts;
        };

        jQuery.validator.methods.greaterThanDate = function(value, element, param) {
            var date1 = new Date(Date.parse(param.replace(/-/g, "/")));
            var date2 = new Date(Date.parse(value.replace(/-/g, "/")));
            return date1 < date2;
        };

        jQuery.validator.methods.lessThanDate = function(value, element, param) {
            var date1 = new Date(Date.parse(param.replace(/-/g, "/")));
            var date2 = new Date(Date.parse(value.replace(/-/g, "/")));
            return date1 > date2;
        };

        jQuery.validator.methods.greaterThanStartDate = function(value, element) {
            var start_date = $("#start_time").val();
            var date1 = new Date(Date.parse(start_date.replace(/-/g, "/")));
            var date2 = new Date(Date.parse(value.replace(/-/g, "/")));
            return date1 < date2;
        };

        jQuery.validator.methods.checkGroupbuyGoods = function(value, element) {
            var start_time = $("#start_time").val();
            var result = true;
            $.ajax({
                type:"GET",
                url:"<?php echo url('Groupbuy/check_groupbuy_goods'); ?>",
                async:false,
                data:{start_time: start_time, goods_id: value},
                dataType: 'json',
                success: function(data){
                    if(!data.result) {
                        result = false;
                    }
                }
            });
            return result;
        };

        //页面输入内容验证
        $("#add_form").validate({
            errorPlacement: function(error, element){
                var error_td = element.parent('dd').children('span');
                error_td.append(error);
            },
            onfocusout: false,
            submitHandler:function(form){
                ds_ajaxpost('add_form','url',"<?php echo url('goods/index'); ?>");
            },
            rules : {
                groupbuy_name: {
                    required : true
                },
                start_time : {
                    required : true
                },
                end_time : {
                    required : true,
        lessThanVrExpireTime : true,
            greaterThanStartDate : true
    },
        groupbuy_goods_id: {
            required : true,
                checkGroupbuyGoods: true
        },
        groupbuy_price: {
            required : true,
                number : true,
                min : 0.01,
                max : 1000000
        },
        virtual_quantity: {
            required : true,
                digits : true
        },
        upper_limit: {
            required : true,
                digits : true,
                lessThanVrLimitNum : true
        },
        groupbuy_image2: {
            required : true
        }
    },
        messages : {
            groupbuy_name: {
                required : '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('group_name_error')); ?>'
            },
            start_time : {
                required : '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('start_time_cannot_empty')); ?>'
            },
            end_time : {
                required : '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('end_snap_time_cannot_empty')); ?>',
                lessThanVrExpireTime : '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('virtual_product_expiration_time')); ?>',
                greaterThanStartDate : '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('must_greater_start_time')); ?>'
            },
            groupbuy_goods_id: {
                required : '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('group_goods_error')); ?>',
                    checkGroupbuyGoods: '<?php echo htmlentities(lang('simultaneous_activities')); ?>'
            },
            groupbuy_price: {
                required : '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('groupbuy_price_error')); ?>',
                    number : '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('groupbuy_price_error')); ?>',
                    min : '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('groupbuy_price_error')); ?>',
                    max : '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('groupbuy_price_error')); ?>'
            },
            virtual_quantity: {
                required : '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('virtual_quantity_error')); ?>',
                    digits : '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('virtual_quantity_error')); ?>'
            },
            upper_limit: {
                required : '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('sale_quantity_error')); ?>',
                digits : '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('sale_quantity_error')); ?>',
                lessThanVrLimitNum : '<?php echo htmlentities(lang('limited_quantity_intended_product_itself')); ?>'
            },
            groupbuy_image2: {
                required : '<i class="iconfont">&#xe64c;</i><?php echo htmlentities(lang('snap_images_cannot_empty')); ?>'
            }
        }
    });

        $('#li_1').click(function(){
            $('#li_1').attr('class','active');
            $('#li_2').attr('class','');
            $('#demo').hide();
        });

        $('#goods_demo').click(function(){
            $('#li_1').attr('class','');
            $('#li_2').attr('class','active');
            $('#demo').show();
        });

        $('.des_demo').click(function(){
            if($('#des_demo').css('display') == 'none'){
                $('#des_demo').show();
            }else{
                $('#des_demo').hide();
            }
        });

        $('.des_demo').ajaxContent({
            event:'click', //mouseover
            loaderType:"img",
            loadingMsg:"<?php echo htmlentities(HOME_SITE_ROOT); ?>/images/loading.gif",
            target:'#des_demo'
        });
    });
    function insert_editor(file_path){
        ue.execCommand('insertimage', {src:file_path});
    }

</script>

    
    
</div>

